package com.kerbores.blog.module;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;

import com.kerbores.blog.bean.Article;
import com.kerbores.blog.module.common.BaseModule;
import com.kerbores.blog.service.IArticleService;
import com.kerbores.blog.service.ICatalogService;
import com.kerbores.utils.entries.Result;
import com.kerbores.utils.web.pager.Pager;

/**
 * @author 贵源 <br>
 *         create at 2014年10月22日
 */
@At("catalog")
public class CatalogModule extends BaseModule {
	@Inject
	private IArticleService articleService;
	@Inject
	private ICatalogService catalogService;

	@At("/*")
	@Ok("vel:blog/list.vm")
	public Result catalog(int id, int page) {
		Pager<Article> pager = articleService.findByCatalog(id, _fixPage(page));
		pager.setUrl("/catalog/" + id);
		pager.setSimplePager(true);
		data.put("pager", pager);
		return Result.success(data).setTitle("文章分类 -- " + catalogService.get(id).getName());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.kerbores.blog.module.common.BaseModule#_getNameSpace()
	 */
	@Override
	public String _getNameSpace() {
		return "catalog";
	}

}
